#!/usr/bin/env python
# coding: utf-8

# In[2]:


import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import sklearn


# In[9]:


data=pd.read_csv("./iris.data",header=None,names=['sep_length_cm','sep_width_cm','pet_length_cm','pet_width_cm','cla'])


# In[10]:


data.head()


# In[11]:


data.cla.unique()


# In[12]:


x=data[data.columns[:-1]]


# In[14]:


y=data[data.columns[-1]]


# In[17]:


from sklearn.model_selection import train_test_split


# In[18]:


x_train,x_test,y_train,y_test=train_test_split(x,y)


# In[20]:


x_train.shape,x_test.shape


# In[21]:


from sklearn.ensemble import RandomForestClassifier
model=RandomForestClassifier()


# In[22]:


model.fit(x_train,y_train)


# In[23]:


model.score(x_train,y_train)


# In[24]:


model.score(x_test,y_test)


# In[25]:


model.predict(x_test)


# In[26]:


model.feature_importances_ 


# In[28]:


for i,imp in zip(['sep_length_cm','sep_width_cm','pet_length_cm','pet_width_cm'],model.feature_importances_):
    print(i,':',imp)


# In[ ]:




